/*
This code will provide the coefficients for eTable 1: Enrollment Sensitivity Analyses
Effect estimate for column 4 can be found in the lincom command
*/

log using "$logs\eTable1.txt", replace text name(etable1)

use "$data_deri\enroll_panel", clear


*Panel A: sensitivity analyses, weighted by Medicare Advantage enrollment
*Column 1 - see coefficient for post#q4_prop_flag1#Top 25% Proportional Cuts
xtreg penetration ib2011.year phaseIn##q4_prop_flag post##q4_prop_flag [aweight=eligibles11], fe vce(robust)
outreg2 using "$output\eTable1", excel replace label nocons stats(coef ci) ctitle(Quartile Cuts) addtext(Separate Phase-In Period, YES) keep(1.post#1.q4_prop_flag)

*Column 2 - see coefficient for post#med_prop_flag1#Top 50% Proportional Cuts
xtreg penetration ib2011.year phaseIn##med_prop_flag post##med_prop_flag [aweight=eligibles11], fe vce(robust)
outreg2 using "$output\eTable1", excel append label nocons stats(coef ci) ctitle(Median Cuts) addtext(Separate Phase-In Period, YES) keep(1.post#1.med_prop_flag)

*Column 3 - see coefficient for post#q10_prop_flag1#Top 10% Proportional Cuts
xtreg penetration ib2011.year phaseIn##q10_prop_flag post##q10_prop_flag [aweight=eligibles11], fe vce(robust)
outreg2 using "$output\eTable1", excel append label nocons stats(coef ci) ctitle(Decile Cuts) addtext(Separate Phase-In Period, YES) keep(1.post#1.q10_prop_flag)

*Column 4 - see coefficients for pre_trend and lincom command
xtreg penetration q4_prop_flag ib2011.year q4_yr* pre_trend [aweight=eligibles11], fe vce(robust)
lincom (q4_yr17+q4_yr18+q4_yr19)/3
outreg2 using "$output\eTable1", excel append label nocons stats(coef ci) ctitle(Parallel Trends Test) addtext(Separate Phase-In Period, YES) keep(pre_trend)

*Column 5 - see coefficient for post#c.bnch_cut_prop1
xtreg penetration ib2011.year phaseIn##c.bnch_cut_prop post##c.bnch_cut_prop [aweight=eligibles11], fe vce(robust)
outreg2 using "$output\eTable1", excel append label nocons stats(coef ci) ctitle(Continuous Benchmark) addtext(Separate Phase-In Period, YES) keep(1.post#c.bnch_cut_prop)


*Panel B: sensitivity analyses, unweighted
*Column 1 - see coefficient for post#q4_prop_flag1#Top 25% Proportional Cuts
xtreg penetration ib2011.year phaseIn##q4_prop_flag post##q4_prop_flag, fe vce(robust)
outreg2 using "$output\eTable1", excel append label nocons stats(coef ci) ctitle(Quartile Cuts) addtext(Separate Phase-In Period, YES) keep(1.post#1.q4_prop_flag)

*Column 2 - see coefficient for post#med_prop_flag1#Top 50% Proportional Cuts
xtreg penetration ib2011.year phaseIn##med_prop_flag post##med_prop_flag, fe vce(robust)
outreg2 using "$output\eTable1", excel append label nocons stats(coef ci) ctitle(Median Cuts) addtext(Separate Phase-In Period, YES) keep(1.post#1.med_prop_flag)

*Column 3 - see coefficient for post#q10_prop_flag1#Top 10% Proportional Cuts
xtreg penetration ib2011.year phaseIn##q10_prop_flag post##q10_prop_flag, fe vce(robust)
outreg2 using "$output\eTable1", excel append label nocons stats(coef ci) ctitle(Decile Cuts) addtext(Separate Phase-In Period, YES) keep(1.post#1.q10_prop_flag)

*Column 4 - see coefficients for pre_trend and lincom command
xtreg penetration ib2011.year q4_yr* q4_prop_flag pre_trend, fe vce(robust)
lincom (q4_yr17+q4_yr18+q4_yr19)/3
outreg2 using "$output\eTable1", excel append label nocons stats(coef ci) ctitle(Parallel Trends Test) keep(pre_trend)

*Column 5 - see coefficient for post#c.bnch_cut_prop1
xtreg penetration ib2011.year phaseIn##c.bnch_cut_prop post##c.bnch_cut_prop, fe vce(robust)
outreg2 using "$output\eTable1", excel append label nocons stats(coef ci) ctitle(Continuous Benchmark) addtext(Separate Phase-In Period, YES) keep(1.post#c.bnch_cut_prop)


*Panel C: sensitivity analyses, weighted by Medicare population, no washout period
*Column 1 - see coefficient for post#q4_prop_flag1#Top 25% Proportional Cuts
xtreg penetration ib2011.year post_alt##q4_prop_flag [aweight=eligibles11], fe vce(robust)
outreg2 using "$output\eTable1", excel append label nocons stats(coef ci) ctitle(Quartile Cuts) addtext(Combined Post Period, YES) keep(1.post_alt#1.q4_prop_flag)

*Column 2 - see coefficient for post#med_prop_flag1#Top 50% Proportional Cuts
xtreg penetration ib2011.year post_alt##med_prop_flag [aweight=eligibles11], fe vce(robust)
outreg2 using "$output\eTable1", excel append label nocons stats(coef ci) ctitle(Median Cuts) addtext(Combined Post Period, YES) keep(1.post_alt#1.med_prop_flag)

*Column 3 - see coefficient for post#q10_prop_flag1#Top 10% Proportional Cuts
xtreg penetration ib2011.year post_alt##q10_prop_flag [aweight=eligibles11], fe vce(robust)
outreg2 using "$output\eTable1", excel append label nocons stats(coef ci) ctitle(Decile Cuts) addtext(Combined Post Period, YES) keep(1.post_alt#1.q10_prop_flag)

*Column 4 - see coefficients for pre_trend and lincom command
xtreg penetration q4_prop_flag ib2011.year q4_yr* pre_trend [aweight=eligibles11], fe vce(robust)
lincom (q4_yr12+q4_yr13+q4_yr14+q4_yr15+q4_yr16+q4_yr17+q4_yr18+q4_yr19)/8
outreg2 using "$output\eTable1", excel append label nocons stats(coef ci) ctitle(Parallel Trends Test) keep(pre_trend)

*Column 5 - see coefficient for post#c.bnch_cut_prop1
xtreg penetration ib2011.year post_alt##c.bnch_cut_prop [aweight=eligibles11], fe vce(robust)
outreg2 using "$output\eTable1", excel append label nocons stats(coef ci) ctitle(Continuous Benchmark) addtext(Combined Post Period, YES) keep(1.post_alt#c.bnch_cut_prop)

log close etable1
